package com.heima.wemedia.feign;

import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.admin.dtos.NewsAuthDto;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.dtos.WmSensitive;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.service.WmNewsService;
import com.heima.wemedia.service.WmSensitiveService;
import com.heima.wemedia.service.WmUserService;
import com.heima.wemedia.service.impl.WmChannelServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class WemediaClient implements IWemediaClient {

    @Autowired
    private WmSensitiveService wmSensitiveService;

    @Autowired
    private WmChannelServiceImpl wmChannelService;

    @Autowired
    private WmUserService wmUserService;

    @Override
    @PostMapping("/api/v1/wmsensitive/list")
    public PageResponseResult list(@RequestBody SensitiveDto dto) {
        return (PageResponseResult) wmSensitiveService.sensitiveList(dto);
    }

    @Override
    @PostMapping("/api/v1/wmsensitive/save")
    public ResponseResult save(@RequestBody WmSensitive wmSensitive) {
        return wmSensitiveService.sensitiveSave(wmSensitive);
    }

    @Override
    @DeleteMapping("/api/v1/wmsensitive/del/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return wmSensitiveService.sensitiveDelete(id);
    }

    @Override
    @PostMapping("/api/v1/wmsensitive/update")
    public ResponseResult update(@RequestBody WmSensitive wmSensitive) {
        return wmSensitiveService.sensitiveUpdate(wmSensitive);
    }

    @Autowired
    private WmNewsService wmNewsService;

    @Override
    @PostMapping("/api/v1/wmnews/list_vo")
    public PageResponseResult listVO(@RequestBody NewsAuthDto dto) {
        return wmNewsService.listVO(dto);
    }

    @Override
    @GetMapping("/api/v1/wmnews/one_vo/{id}")
    public ResponseResult getOneVO(@PathVariable Integer id) {
        return wmNewsService.getOneVO(id);
    }

    @Override
    @PostMapping("/api/v1/wmnews/authFail")
    public ResponseResult authFail(NewsAuthDto dto) {
        return wmNewsService.authFail(dto);
    }

    @Override
    @PostMapping("/api/v1/wmnews/authPass")
    public ResponseResult authPass(NewsAuthDto dto) {
        return wmNewsService.authPass(dto);
    }

    @Override
    @PostMapping("/api/v1/wmuser/saveAuth")
    public void saveAuth(@RequestBody WmUser wmUser) {
        wmUserService.saveAuth(wmUser);
    }


    @Override
    @PostMapping("/api/v1/wmchannel/list")
    public PageResponseResult list(@RequestBody WmChannelDto wmChannelDto) {
        return (PageResponseResult) wmChannelService.list(wmChannelDto);
    }

    @Override
    @PostMapping("/saveChannel")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel) {
        return wmChannelService.saveChannel(wmChannel);
    }

    @Override
    @GetMapping("/deleteChannel/{id}")
    public ResponseResult deleteChannelByid(@PathVariable Integer id) {
        System.out.println(id);
        return wmChannelService.deleteChannel(id);
    }

    @Override
    @PostMapping("/updateChannel")
    public ResponseResult updateChannelByid(WmChannel wmChannel) {

        return wmChannelService.update(wmChannel);
    }

}
